package com.echo.im.engin.netty.processor.support.in;

import com.echo.im.common.dto.MessageDTO;
import com.echo.im.engin.packet.in.GroupMessageInPacket;
import com.echo.im.engin.netty.processor.preprocessor.PreprocessorContext;
import com.echo.im.engin.netty.processor.MessageInProcessor;
import com.echo.im.engin.pipeline.GroupMessageProcessPipeline;
import io.netty.channel.ChannelHandlerContext;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author: echo
 * @time: 2024-08-22
 */
@Component
@RequiredArgsConstructor
public class GroupMessageInProcessor implements MessageInProcessor<GroupMessageInPacket> {

    private final PreprocessorContext preprocessorContext;

    private final GroupMessageProcessPipeline groupMessageProcessPipeline;

    @Override
    public void inProcess(ChannelHandlerContext ctx, GroupMessageInPacket packet) {
        MessageDTO<GroupMessageInPacket> messageDTO = new MessageDTO<>(packet);

        preprocessorContext.doPreprocess(messageDTO);

        groupMessageProcessPipeline.processMessage(messageDTO);

    }


}
